package com.test.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.test.mapper.PeopleMapper;
import com.test.po.People;
import com.test.po.PeopleExample;

@Service
public class PeopleServiceImpl    extends ServiceImpl<PeopleMapper, People> implements PeopleService{

	@Autowired
	private PeopleMapper peopleMapper;

	public PageInfo<People> getUPeople(int page, int pageSize) {
		// People users=peopleMapper.selectByPrimaryKey(1);
		PageHelper.startPage(page, pageSize);
		PeopleExample example = new PeopleExample();
		example.createCriteria().andPnameEqualTo("2");
		List<People> peoples = (List<People>) peopleMapper.selectByExample(example);
		PageInfo<People> peopleList = new PageInfo<People>(peoples, pageSize);
		return peopleList;
	}

	public PageInfo<People> getPeopleUnion(int page, int pageSize) {
		PageHelper.startPage(page, pageSize); 
		List<People> peoples = (List<People>) peopleMapper.selectPeopleList();
		PageInfo<People> peopleList = new PageInfo<People>(peoples, pageSize);
		return peopleList;
	} 

	@Override
	public int savePeople(People people) {
		int j = 1/0;
		return peopleMapper.insert(people);
	}
}
